<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@ include file="/WEB-INF/views/modules/commons/head.jsp" %>
    <title>重大项目节点系统-确认节点的项目</title>
    <!-- 我的项目CSS -->
    <link rel="stylesheet" href="<s:url value="/assets/web/css/my/myproject.css"></s:url>">
    <!-- 复选框 -->
    <link rel="stylesheet" href="<s:url value="/assets/web/common/lulu_zujian/ui.css"></s:url>">
    <style>
        /* 显示区域边距 */
        #content-main {
            padding: 30px 30px 0;
            margin-left: 17.5%;
        }

        select {
            width: 80px;
            height: 35px;
            margin-right: 10px;
            opacity: 1;
            border-right-width: 0px;
        }

        input {
            width: 120px;
            height: 35px;
            margin-right: 10px;
        }

        button {
            background: #33CCFF;
            border: none;
            width: 50px;
            height: 35px;
            border-radius: 5px;
            color: #fff;
        }

        #username-right button {
            width: 110px;
        }
    </style>
    <head>
        <title>Title</title>
    </head>
<body style="margin:0;padding: 0;">
<%@ include file="/WEB-INF/views/modules/commons/nav.jsp" %>
<%@ include file="/WEB-INF/views/modules/commons/menu.jsp" %>
<table></table>
<div class="av row J_mainContent bgcolor" id="content-main">
    项目名:<input type="text" id="projectName">
    责任单位:<input type="text" id="resDept">
    状态:<select id="status">
    <option value="">请选择</option>
    <option value="1">审批节点待确定</option>
    <option value="2">节点确定完毕</option>
</select>
    <input type="hidden" id="pages">
    <button class="search-btn" id="queryData">搜索</button>
    <button class="search-btn" id="resetData">重置</button>
    <table class="project-info">
        <thead>
        <tr>
            <th>编号</th>
            <th>项目名称</th>
            <th>责任单位</th>
            <th>分管领导</th>
            <th>投资金额</th>
            <th>状态(点击进去详细)</th>
        </tr>
        </thead>
        <tbody id="index-main">

        </tbody>
    </table>
    <!-- 分页 -->
    <div class="footer text-center">
        <ul class="pagination" id="pagination0"></ul>
    </div>
</div>
<%@ include file="/WEB-INF/views/modules/commons/foot.jsp" %>
<script>
    $(function () {
        // 点击显示或隐藏二级列表
        $("#audit").parent()
            .mouseover(function () {
                $(this).children(".nav-second-level").show();
            })
            .mouseout(function () {
                $(this).children(".nav-second-level").hide();
            });
        //分页
        $('#pagination0').jqPaginator({
            totalPages: ${totalPage},
            visiblePages: 5,
            currentPage: 1,
            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num) {

                console.log(num);
                $('#text').html('当前第' + num + '页');
                //获取状态值
                var status = $("#status").text();
                $.ajax({
                    type: "GET",
                    url: "/accraditation/getProjectslist",
                    dataType: "json",
                    data: {page: num},
                    success: function (data) {

                        console.log(data);
                        var html = "";
                        for (var i = 0; i < data.model.length; i++) {
                            s = '';
                            var list = data.model[i];
                            if (list.status == 0) {
                                s = '<td><a style="color:red;" href="/accraditation/go/configNode?sysId=' + list.sysId + '">节点信息待确认</a></td>';
                            } else if (list.status == 1) {
                                s = '<td><a style="color:orange;" href="/accraditation/go/configNode?sysId=' + list.sysId + '">部分节点未确认</a></td>'
                            } else {
                                s = '<td><a href="/accraditation/go/configNode?sysId=' + list.sysId + '">节点确认完毕</a></td>'
                            }
                            html += '<tr>'
                                + '<td>' + list.updUser + '</td>'
                                + '<td>' + list.name + '</td>'
                                + '<td>' + (list.resDept == undefined ? "" : list.resDept) + '</td>'
                                + '<td>' + (list.resUser == undefined ? "" : list.resUser) + '</td>'
                                + '<td>' + (list.money == undefined ? "" : list.money) + '万元</td>'
                                + '' + s + ''
                                + '</tr>';
                        }
                        $("#index-main").html(html);
                        //赋值总页数
                        $("#pages").val(data.totalPage);
                        pagg = Number($("#pages").val());
                        //调用分页插件修改查询总页数
                        $('#pagination0').jqPaginator('option', {
                            totalPages: pagg,
                        });
                    },
                    error: function () {
                        console.log("发生错误");
                    }
                });
            }
        });
    })
    $("#queryData").click(function () {
        $('#pagination0').jqPaginator({
            totalPages: 1,
            visiblePages: 5,
            currentPage: 1,
            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num) {
                $('#text').html('当前第' + num + '页');
                //获取状态值
                var status = $("#status").text();
                var projectName = $("#projectName").val();
                var resDept = $("#resDept").val();
                var status = $("#status").val();
                $.ajax({
                    type: "GET",
                    url: "/accraditation/getProjectslist",
                    dataType: "json",
                    data: {page: num, "name": projectName, "resDept": resDept, "status": status},
                    success: function (data) {
                        console.log(data);
                        var html = "";
                        for (var i = 0; i < data.model.length; i++) {
                            s = '';
                            var list = data.model[i];
                            if (list.status == 0) {
                                s = '<td><a style="color:red;" href="/accraditation/go/configNode?sysId=' + list.sysId + '">节点信息待确认</a></td>';
                            } else if (list.status == 1) {
                                s = '<td><a style="color:orange;" href="/accraditation/go/configNode?sysId=' + list.sysId + '">部分节点未确认</a></td>'
                            } else {
                                s = '<td><a href="/accraditation/go/configNode?sysId=' + list.sysId + '">节点确认完毕</a></td>'
                            }

                            html += '<tr>'
                                + '<td>' + list.updUser + '</td>'
                                + '<td>' + list.name + '</td>'
                                + '<td>' + (list.resDept == undefined ? "" : list.resDept) + '</td>'
                                + '<td>' + (list.resUser == undefined ? "" : list.resUser) + '</td>'
                                + '<td>' + (list.money == undefined ? "" : list.money) + '万元</td>'
                                + '' + s + ''
                                + '</tr>';
                        }
                        $("#index-main").html(html);
                        $("#page").html(num);
                        //赋值总页数
                        $("#pages").val(data.totalPage);
                        pagg = Number($("#pages").val());
                        //调用分页插件修改查询总页数
                        $('#pagination0').jqPaginator('option', {
                            totalPages: pagg,
                        });
                    },
                    error: function () {
                        console.log("发生错误");
                    }
                });
            }
        });

    });
    $("#resetData").click(function () {
        $("#projectName").val("");
        $("#resDept").val("");
        $("#status").val("");
    });

</script>
</body>
</html>
